<?php


$libraryPath = '../../library';


// Display errors. Disable on production servers.
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', true);


// Append the Library folder to include_path.
if ($libraryPath{0} != '/' && $libraryPath{1} != ':')
	$libraryPath = realpath($libraryPath);
define('LIBRARY_PATH', $libraryPath);
define('BASE_PATH', dirname(__FILE__));
define('BASE_URL', str_replace('/index.php', '', $_SERVER["SCRIPT_NAME"]));
define('HTMLPURIFIER_PREFIX', LIBRARY_PATH . '/HTMLPurifier');
set_include_path(get_include_path() . PATH_SEPARATOR . LIBRARY_PATH);


// Register the autoloader callback method.
require 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);


// Setup environment.
date_default_timezone_set('America/Bogota');
Zend_Locale::setDefault('es_CO');
Zend_Registry::set('Zend_Locale', new Zend_Locale('es_CO'));


// Load database configuration and make it available for controllers.
$config = new Zend_Config(require LIBRARY_PATH . '/Blackbird/config/general.php');
$database = Zend_Db::factory($config->database->adapter, $config->database->params);
$database->setFetchMode(Zend_Db::FETCH_OBJ);
Zend_Registry::set('database', $database);
Zend_Db_Table_Abstract::setDefaultAdapter($database);


// Initialize views.
$view = new Zend_View;
$view->setEncoding('UTF-8');
$viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view);
Zend_Controller_Action_HelperBroker::addHelper($viewRenderer);
Zend_Layout::startMvc(array('layoutPath' => LIBRARY_PATH . '/VendemeGratis/layouts'));


// Inject the ContentRoute and start the execution of the request.
Zend_Controller_Front::getInstance()
	->throwExceptions(true);
Zend_Controller_Front::run($libraryPath . '/Blackbird/admin');

